<html>
<head>
<title>jQueryGears GeoLocation Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
#map_canvas img.load{
	position: relative;
	top:188px;
	left:188px;
}
#map_canvas {
	border: 1px solid gray;
}
</style>
</head>
<body>
<div id="message_place"></div>
<div id="map_canvas" style="width: 400px; height: 400px;">
<img class='load' src="load.gif" />
</div>
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAqST4dCrRr3VUA2hQx-BamhQt0XSEiQUzp7URcxf64ckLPsduCBS1iWkO-w5ab27fQK7ceEBn7LWZHw"></script>
<script>
// Load jQuery
google.load("jquery", "1");
google.load("maps", "2");
window.onload = function(){
var geo = $.gears('beta.geolocation');
	if($.gears.userPermission){
		if(geo){
			// If Gears install
		    geo.getCurrentPosition(function(position){
		        var map;
			    var geocoder;
			    var address;
			      map = new GMap2(document.getElementById("map_canvas"));
			      map.setCenter(new GLatLng(position.latitude,position.longitude), 10);
			      map.addControl(new GLargeMapControl);
			      //GEvent.addListener(map, "click", getAddress);
			      point = new GLatLng(position.latitude,position.longitude);
		          marker = new GMarker(point);
		          map.addOverlay(marker);
			      geocoder = new GClientGeocoder();
			      
			      var address = position.gearsAddress.city + ', '
                  + position.gearsAddress.region + ', '
                  + position.gearsAddress.country + ' ('
                  + position.latitude + ', '
                  + position.longitude + ')';
			    
		       $('#message_place').html('Вы нахожитесь: ' + address);
		    }, function(positionError){
		       $('#message_place').html('Attempt to get location failed: ' + positionError.message);
		    },{ enableHighAccuracy: true,gearsRequestAddress: true });
		   }else{
			// Else Gears NOT install
		      $.gears.install({element:'#message_place'});   
		   }
	}
}
</script>
<script src="jquery.gears.js"></script>
</body>
</html>
